<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    //json和js对象非常类似，差别只是js对象属性没有双引号包含，而json的属性必须使用双引号包含
    var json1 = {"name":"zs","age":20};
    console.log(json1); // {name: "zs", age: 20} (是js中的对象形式)
    alert(json1.name); //zs
    alert(json1.age); // 20

    var json2 = {
      "name" : "郭德纲",
      "cp" : "于谦",
      "tudi" : ["曹云金","何云伟"],
      "son" : {"name" : "郭麒麟", "age" : 28, "gender" : "男"}
    };
    alert(json2.name); // 郭德纲
    alert(json2.tudi[1]); // 何云伟
    alert(json2.son.name); // 郭麒麟

    var json3 = [
      {"name" : "大头儿子", "age" : 6},
      {"name" : "小头爸爸", "age" : 35},
      {"name" : "隔壁老王", "age" : 40}
    ];
    alert(json3[1].name); // 小头爸爸
  </script>
</body>
</html>